#include <iostream>
#include <cstring>
using namespace std;

const int N = 1e4 + 5;
int n;
int dp[N];

int main()
{
    cin >> n;
    memset(dp, 0x3f3f3f, sizeof dp);
    dp[0] = 0;

    for (int i = 1; i * i <= n; i++)
        for (int j = i * i; j <= n; j++)
            dp[j] = min(dp[j], dp[j - i * i] + 1);

    cout << dp[n] << endl;
    return 0;
}
